<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	    <meta name="viewport" content="width=device-width, initial-scale=1">
	    <title>管理员信息</title>		
		<link rel="shortcut icon" href="assets/ico/favicon.ico" type="image/x-icon" />
	    <link href="assets/css/bootstrap.min.css" rel="stylesheet">
		<link href="assets/css/jquery.mmenu.css" rel="stylesheet">
		<link href="assets/css/font-awesome.min.css" rel="stylesheet">
		<link href="assets/plugins/jquery-ui/css/jquery-ui-1.10.4.min.css" rel="stylesheet">
	    <link href="assets/css/style.min.css" rel="stylesheet">
		<link href="assets/css/add-ons.min.css" rel="stylesheet">
		<title></title>
		<script src="assets/js/jquery-1.4.1.js"></script>
	</head>
	<body>
		<div class="row profile">
				<div class="col-md-5">
					<div class="panel panel-default">
						<div class="panel-body">
							<div class="text-center">
								<!--管理员头像-->
								<img class="img-profile" src="assets/img/avatar.jpg">
							</div>
							<h3 id="admin" class="text-center"></h3>
							<hr>
								<div class="text-center">								
									<li><a href="" class="fa fa-facebook facebook-bg"></a></li>
									<li><a href="" class="fa fa-twitter twitter-bg"></a></li>
									<li><a href="" class="fa fa-linkedin linkedin-bg"></a></li>						
								</div>
							<hr>	
							<hr>		

							<h4><strong>联系方式</strong></h4>

							<ul class="profile-details">
								<li>
									<div id="adminName"><i class="fa fa-phone"></i>联系电话</div>

								</li>
								<li>
									<div id="adminAuthority"><i class="fa fa-asterisk"></i>权限</div>

								</li>
								<li>
									<div id="adminEmali"><i class="fa fa-envelope"></i> E-mail</div>

								</li>
								<li>
									<div id="adminAddress"><i class="fa fa-map-marker"></i>家庭地址</div>

								</li>
							</ul>	
							
						</div>	
						
					</div>
				
				</div><!--/.col-->
					<div class="col-md-7">
				
                    <div class="panel panel-default">                               
                        <div class="panel-heading">
                            <h2><i class="fa fa-heart-o red"></i><strong>修改管理员信息</strong></h2>
							<!--<h2><i class="fa fa-heart-o red"></i><a href="/addadmin.html" >添加管理员信息</a></h2>-->

                        </div>
                        <div class="panel-body">
                            <form class="form-vertical hover-stripped" role="form" action="/updateadmin" method="post">
                                <div class="form-group">
                                    <label class="control-label">管理员账户</label>
									<input type="text" name="adminname" class="form-control" value="" readonly>
                                </div>
                                
                                <div class="form-group">
                                    <label class="control-label">管理员邮箱</label>
                                    <input type="email" class="form-control" name="adminemali" value="">
                                </div>
                                <div class="form-group">
                                    <label class="control-label">联系电话</label>
                                    <input type="text" name="adminphone" value="" class="form-control">
                                </div>
								<div class="form-group">
                                    <label class="control-label">新密码</label>
                                    <input type="password" name="adminpwd" value="" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label class="control-label">确认密码</label>
                                    <input type="password" name="adminpwd2" value="" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label class="control-label">家庭地址</label>
									<textarea class="form-control" name="adminaddress" value="" rows="3"></textarea>
								</div>
                                        
                                <div class="form-group pull-right">
                                    <button type="submit" class="btn btn-primary">确定修改</button>
                                </div>
                                        
                            </form>
                        </div>
                    </div>
					
				</div><!--/.col-->
			
			</div><!--/.row profile-->				
		</div>
	</body>
	<script src="assets/js/jquery-1.4.1.js"></script>
	<script type="text/javascript">
          $(function(){

              $.ajax({
                  url: "/queryAdmin",
                  type: "post",
                  success: function(caradmininfo) {
                      console.log(caradmininfo)
                      $("#admin").append(caradmininfo.adminname);
                      $("#adminName").after(caradmininfo.adminname);
                      $("#adminAuthority").after(caradmininfo.adminauthority);
                      $("#adminAddress").after(caradmininfo.adminaddress);
                      $("#adminEmali").after(caradmininfo.adminemali);
                      $("input[name='adminname']").val(caradmininfo.adminname);
                      $("input[name='adminemali']").val(caradmininfo.adminemali);
                      $("textarea[name='adminAddress']").val(aradmininfo.adminaddress);
                  }
              });



              //要求验证密码至少是8位数，必须输入字母数字或者下划线
		 	   	   //先得到密码框给密码框绑定离开事件
		 	   	   $("input[name=adminpwd]").bind("blur",function(){
		 	   	   	  //清空
		 	         $(this).nextAll("span").remove();
		 	   	   	   //得到当前密码框的值
		 	   	   	   var pwd1Val=$(this).val();
		 	   	   	   //对密码进行验证
		 	   	   	   if(pwd1Val.length<8){
		 	   	   	   	   //如果不通过就给出提示
		 	   	         $("input[name=adminpwd]").after("<span>密码不能小于8为数</span>");
		 	   	   	   }
		 	   	   });
		 	   	   $("input[name=adminemali]").bind("blur",function(){
		 	   	   	  //清空
		 	         $(this).nextAll("span").remove();
		 	         var Emali=$(this).val();
		 	         if(Emali==null){
		 	         	  //如果不通过就给出提示
		 	   	         $("input[name=adminemali]").after("<span>邮箱不能为空</span>");
		 	         }
		 	   	   });
		 	   	   
		 	   	   //验证地址
		 	   	   $("input[name=adminAddress]").bind("blur",function(){
		 	   	   	  //清空
		 	         $(this).nextAll("span").remove();
		 	         var address=$(this).val();
		 	         if(address==null){
		 	         	  //如果不通过就给出提示
		 	   	         $("input[name=adminAddress]").after("<span>地址不能为空</span>");
		 	         }
		 	   	   });
		 	   	   
		 	   	   $("input[name=adminPhone]").bind("blur",function(){
		 	   	   	  //清空
		 	         $(this).nextAll("span").remove();
		 	         var Phone=$(this).val();
		 	         if(Phone==null){
		 	         	  //如果不通过就给出提示
		 	   	         $("input[name=adminPhone]").after("<span>联系电话不能为空</span>");
		 	         }
		 	   	   });
		 	   	   
		 	   	   //验证两次密码是否一致
		 	   	    $("input[name=adminPwd2]").bind("blur",function(){
		 	   	    	  //清空
		 	         $(this).nextAll("span").remove();
		 	   	   	   //得到当前密码框的值
		 	   	   	   var pwd2Val=$(this).val();
		 	   	   	   var pwd1val=$("input[name=adminPwd]").val();
		 	   	   	   //对密码进行验证
		 	   	   	   if(pwd2Val!=pwd1val){
		 	   	   	   	   //如果不通过就给出提示
		 	   	         $("input[name=adminPwd2]").after("<span>两次密码不正确</span>");
		 	   	   	   }
		 	   	    });
		 	   	    
		 	     //绑定提交事件
		 	   	   $("form").bind("submit",function(){
		 	   	   	   //让form表单默认执行blur()方法
		 	   	   	   $("form").trigger("blur");
		 	   	   	   //如果span标签有值就表示有错误信息不能提交表单
		 	   	   	   if($("span").length>0){
		 	   	   	   	  return false;
		 	   	   	   }
		 	   	   });
          });
		</script>
 </html>
